﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BoletoElectronicoDesktop.InactividadTarjetas
{
    public partial class FormInactividadTarjetas : Form
    {
        public DataTable dt;
        public FormInactividadTarjetas()
        {
            InitializeComponent();
        }

        private void FormInactividadTarjetas_Load(object sender, EventArgs e)
        {
            //abro el formulario maximizado
            this.WindowState = FormWindowState.Maximized;
            btnBaja.Enabled = false;
        }

        private void btnBuscar_Click(object sender, EventArgs e)
        {
            dt = TarjetaDAO.ObtenerTarjetasAInhabilitar();
            dataGridView1.DataSource = dt;
            dataGridView1.Columns["numeroTarjeta"].Visible = false;
            if (dt.Rows.Count > 0)
                btnBaja.Enabled = true;
            else
            {
                MessageBox.Show("No hay tarjetas para inhabilitar");
            }
        }

        private void btnBaja_Click(object sender, EventArgs e)
        {
          for (int i = 0; i < dt.Rows.Count; i++)
            {
                TarjetaDAO.InhabilitarTarjeta(dt.Rows[i]["numeroTarjeta"].ToString());
            }
            MessageBox.Show("Tarjetas inhabilitadas con éxito");
            
            dt = TarjetaDAO.ObtenerTarjetasAInhabilitar();
            dataGridView1.DataSource = dt;
            btnBaja.Enabled = false;
        
        }


    }
}
